/*
 * @Author: 陈俊升 761723995@qq.com
 * @Date: 2023-11-08 08:51:15
 * @LastEditors: 陈俊升 761723995@qq.com
 * @LastEditTime: 2023-12-14 14:46:39
 * @FilePath: /hr_new_vue3/src/apis/management/contract/baseSetting/index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
/* 合同-待签署合同列表api */

import { ajaxService } from '@/utils/request';

const env = import.meta.env;
// const baseURL1 = env.VITE_API_BASE_URL;
const baseURL = env.VITE_DEV_BASE_URL;
// const baseURL = env.VITE_APP_BASE_URL;
const baseURL2 = env.VITE_APP_BASE_URL;
const baseURL3 = env.VITE_DEV_BASE_URL;

/**
 * 获取签署合同列表
 */
export function GetWaitSignedContractList(params: any) {
  return ajaxService({
    url: '/hr/personnel_matters/roster/personnel/contract',
    method: 'get',
    params,
    baseURL
  });
}

/**
 * 获取用户对应status的合同列表
 */
export function GetUserContractByStatusDetail(params: {
  userId: number;
  status: number;
}) {
  return ajaxService({
    url: '/hr/contract/basic_setting/contract_list/detail',
    method: 'get',
    params,
    baseURL
  });
}

/**
 * 根据id修改单个合同内文件
 */
export function EditContractFile(data: any) {
  return ajaxService({
    url: '/hr/contract/basic_setting/contract_list/use',
    method: 'put',
    data,
    baseURL
  });
}

/**
 * 修改合同status
 */
export function EditContractStatus(data: {
  id: number;
  status: number;
  returnReason?: string;
}) {
  return ajaxService({
    url: '/hr/contract/basic_setting/contract_list/status',
    method: 'put',
    data,
    baseURL
  });
}
/**
 * 新增起草合同(确认并保存)
 */
export function DraftWaitSignedContractSave(data: any) {
  return ajaxService({
    url: '/hr/contract/basic_setting/contract_list',
    method: 'post',
    data,
    baseURL
  });
}

/**
 * 修改起草合同(确认并保存)
 */
export function DraftWaitSignedContractSavePut(data: any) {
  return ajaxService({
    url: '/hr/contract/basic_setting/contract_list',
    method: 'put',
    data,
    baseURL
  });
}

/**
 * 发起起草合同同时修改状态
 */
export function DraftWaitSignedContractSavePutStatus(data: {
  ids: number[];
  status: number;
  returnReason?: string;
}) {
  return ajaxService({
    url: '/hr/personnel_matters/roster/personnel/c/status',
    method: 'put',
    data,
    baseURL
  });
}

/**
 * 转换起草合同模板控件的code
 */
export function SwitchDraftWaitSignedContract(params: {
  id: number; // 人员id
  text: string;
  codes: string;
}) {
  return ajaxService({
    url: '/hr/contract/basic_setting/contract_list/text',
    method: 'get',
    params,
    baseURL
  });
}

/**
 * 获取合同编号
 */
export function GetGenerateContractNum(params: {
  id: number; // 合同类型id
  userId: number; // 人员id
}) {
  return ajaxService({
    url: '/hr/contract/basic_setting/contract_list/contract/num',
    method: 'get',
    params,
    baseURL
  });
}

/**
 * 修改签署状态
 */
export function ChangeWaitSignedContractState(data: {
  id: number; // 人员id
  status: number; // 签署状态 1待起草2起草不通过3待提交4待确认5已退回6待审批7审批不通过8待签署9已签署10已作废
}) {
  return ajaxService({
    url: '/hr/contract/basic_setting/contract_list/contract/status',
    method: 'put',
    data,
    baseURL
  });
}

/**
 * 确认签署合同
 */
export function ConfirmWaitSignedContractSign(data: any) {
  return ajaxService({
    url: '/hr/contract/basic_setting/contract_list/file',
    method: 'post',
    data,
    baseURL
  });
}

/**
 * 单独修改确认签署合同的信息
 */
export function ChangeConfirmWaitSignedContractSign(data: any) {
  return ajaxService({
    url: '/hr/contract/basic_setting/contract_list/contract/detail',
    method: 'put',
    data,
    baseURL
  });
}

/**
 * 获取确认签署合同文件/附件详情
 */
export function GetConfirmWaitSignedContractSignFile(params: {
  id: number; // 人员id
  typeId: number; // 合同id
}) {
  return ajaxService({
    url: '/hr/contract/basic_setting/contract_list/file',
    method: 'get',
    params,
    baseURL
  });
}
